// // https://www.cnblogs.com/qcloud1001/p/10491411.html

// // https://www.jianshu.com/p/487ed4435647

// // const proxy = new Proxy(fakeWindow, {

// // })


// class ProxySandbox {
//     constructor() {
//         const rawWindow = window;
//         const fakeWindow = {}
//         const proxy = new Proxy(fakeWindow, {
//             set(target, p, value) { target[p] = value; return true },
//             get(target, p) { return target[p] || rawWindow[p]; }
//         });
//         this.proxy = proxy
//     }
// }
// let sandbox1 = new ProxySandbox();
// let sandbox2 = new ProxySandbox();
// window.a = 1;
// ((window) => { window.a = 'hello'; console.log(window.a) })(sandbox1.proxy);
// ((window) => { window.a = 'world'; console.log(window.a) })(sandbox2.proxy);



class ProxyStandbox {
    constructor(){
        const rawWindow = window;
        const fakeWindow = {};
        const proxy = new Proxy(fakeWindow,{
            set(target, key,val){
                target[key] = val;
                return true;
            },
            get(target,key){
                return target[key] || rawWindow[key]
            },
        })
        return proxy
    }
}
let proxy1 = new ProxyStandbox();
let proxy2 = new ProxyStandbox()
((window)=>{window.a = 'hello';consple.log(window.a)})(proxy1.proxy)
((window)=>{window.a = 'b';consple.log(window.a)})(proxy2.proxy)